package MutilReadFile;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class ReadLineTxt    {
	public static void main(String[] args) {
		long begin = System.nanoTime();
		readFileByLines("C:\\a.txt");
		long end = System.nanoTime();
		System.out.println((end - begin) / 1000 + "微秒");
	}

	public static void readFileByLines(String fileName) {
		File file = new File(fileName);
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new FileReader(file));
			//reader.skip(1000);
			String tempString = null;
			int line = 1;
			while ((tempString = reader.readLine()) != null) {
				//System.out.println(tempString+"  行"+line);
				line++;
			}
			System.out.println("行="+line);
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e1) {
				}
			}
		}
	}
}
